package com.boyinet.activation;

import com.boyinet.activation.entity.Permission;
import com.boyinet.activation.service.PermissionService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class Generator {

    @Autowired
    private PermissionService permissionService;

    @Test
    public void buildPermission() {
        List<Permission> permissionList = new ArrayList<>();
        Permission permission1 = new Permission();
        permission1.setTitle("主导航");
        permission1.setGroup(true);
        permission1.setHideInBreadcrumb(true);

        Permission permission2 = new Permission();
        permission2.setTitle("系统");
        permission2.setGroup(true);
        permission2.setHideInBreadcrumb(true);

        Permission permission3 = new Permission();
        permission3.setTitle("业务");
        permission3.setGroup(true);
        permission3.setHideInBreadcrumb(true);

        permissionList.add(permission1);
        permissionList.add(permission2);
        permissionList.add(permission3);

        permissionService.saveBatch(permissionList);
    }

    @Test
    public void buildSubPermission() {
        List<Permission> permissionList = new ArrayList<>();
        Permission permission1 = new Permission();
        permission1.setTitle("订单");
        permission1.setHerf("/order");
        permission1.setIcon("anticon anticon-appstore-o");
        permission1.setPid(1353539809204973569L);

        permissionList.add(permission1);


        permissionService.saveBatch(permissionList);
    }
}
